package Controller.reply;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Bean.ReplyBean;
import Dao.ReplyDao;

public class ReplyreplyInsertController implements Controller{
	private ReplyDao dao;
	
	public void setDao(ReplyDao dao) {
		this.dao = dao;
	}
	@Override
	public ModelAndView handleRequest(HttpServletRequest req,
			HttpServletResponse arg1) throws Exception {
		Integer sr_myno = Integer.parseInt(req.getParameter("sr_no"));
		Integer sr_sb_no = Integer.parseInt(req.getParameter("sb_no"));
		String sr_m_id = req.getParameter("m_id");
		String sr_context = req.getParameter("retext");
		// 
		System.out.println("넘어온 댓글 시퀀스 : "+sr_myno);
		System.out.println("넘어온 게시판 시퀀스 : "+sr_sb_no);
		System.out.println("넘어온 회원 아이디 : "+sr_m_id);
		System.out.println("넘어온 입력 글 : "+sr_context);
		
		ReplyBean rb = new ReplyBean();
		rb.setSr_context(sr_context);
		rb.setSr_m_id(sr_m_id);
		rb.setSr_myno(sr_myno);
		rb.setSr_sb_no(sr_sb_no);
		
		dao.replyreplyInsert(rb);
		ModelAndView mav = new ModelAndView();
		mav.setViewName("redirect:/sBoardReplyList.reply?sb_no="+sr_sb_no);
		System.out.println("리플에 리플달기 완성");
		return mav;
	}
}
